import { useEffect, useState } from 'react'
import { done, start } from 'nprogress'
import { ReactNode } from 'react'

function sta() {
  start()
}
const FancyRoute = ({ children }: { children: ReactNode }) => {
  useState(sta)
  useEffect(() => {
    done()
    return () => sta()
  })
  return <>{children}</>
}
const PageTitle = ({ route }: any) => {
  const { title, element } = route
  useEffect(() => {
    document.title = title || ''
  }, [])
  return <FancyRoute>{element}</FancyRoute>
}
export default PageTitle
